package tests;

import metier.*;
import junit.framework.TestCase;
/**
 * 
 * @author lamballais
 * liste des tests unitaires pour la classe Formation
 */
public class FormationTest extends TestCase {
	
		/**
		 * constructeur de CatalogueTest(String)
		 * appelle le constructeur de TestCase
		 */
		public FormationTest (String nom){
			super(nom);
		}
		
		// tests methodes de consultation
		public void testGet() {
			Formation maFormation = new Formation(1,"Initiation POO",1,4);
			assertEquals(maFormation.getId(),1);
			assertEquals(maFormation.getDuree(),4);
			assertEquals(maFormation.getNiveau(),1);
			assertEquals(maFormation.getDesignation(),"Initiation POO");				
		}
		
		// test methode toString
		public void testToString(){
			Formation maFormation = new Formation(1,"Initiation POO",1,4);
			assertEquals(maFormation.toString(),"1 Initiation POO 1 4");
			assertEquals(maFormation.toString("-"),"1-Initiation POO-1-4");
			assertEquals(maFormation.toString(","),"1,Initiation POO,1,4");
		}
		// test modifie la designation
		public void testSetDesignation() {
			Formation maFormation = new Formation(1,"Initiation POO",1,4);
			assertEquals(maFormation.getDesignation(),"Initiation POO");
			assertEquals(maFormation.toString(),"1 Initiation POO 1 4");
			maFormation.setDesignation("UML-2");
			assertEquals(maFormation.getDesignation(),"UML-2");	
			assertEquals(maFormation.toString(),"1 UML-2 1 4");
		}
				
		// tests change le niveau
		public void testSetNiveau() {
			Formation maFormation = new Formation(2,"Les tests unitaires",3,1);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 3 1");			
			assertEquals(maFormation.getNiveau(),3);
		    //niveau ok
			maFormation.setNiveau(2);
			assertEquals(maFormation.getNiveau(),2);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 2 1");
			//niveau ok
			maFormation.setNiveau(1);
			assertEquals(maFormation.getNiveau(),1);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 1 1");
			//niveau ok
			maFormation.setNiveau(4);
			assertEquals(maFormation.getNiveau(),4);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 4 1");
			//niveau ok
			maFormation.setNiveau(3);
			assertEquals(maFormation.getNiveau(),3);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 3 1");
			//niveau invalide
			maFormation.setNiveau(0);
			assertEquals(maFormation.getNiveau(),1);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 1 1");
			//niveau invalide
			maFormation.setNiveau(5);
			assertEquals(maFormation.getNiveau(),1);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 1 1");
		}	
		
		// tests change la duree
		public void testSetDuree() {
			Formation maFormation = new Formation(2,"Les tests unitaires",3,1);
			assertEquals(maFormation.toString(),"2 Les tests unitaires 3 1");			
			assertEquals(maFormation.getDuree(),1);
			//duree ok
			maFormation.setDuree(7);
			assertEquals(maFormation.getDuree(),7);
			//duree ok
			maFormation.setDuree(0);
			assertEquals(maFormation.getDuree(),0);
			//duree invalide
			maFormation.setDuree(-5);
			assertEquals(maFormation.getDuree(),5);			
		}
		
		// test methode coutFormation
		public void testCoutFormation() {
			Formation maFormation = new Formation(1,"Initiation POO",1,4);
			assertTrue(maFormation.coutFormation()==160);
			maFormation.setNiveau(2);
			assertTrue(maFormation.coutFormation()==200);
			maFormation.setNiveau(3);
			assertTrue(maFormation.coutFormation()==300);
			maFormation.setNiveau(4);
			assertTrue(maFormation.coutFormation()==400);
			maFormation.setNiveau(0);
			assertTrue(maFormation.coutFormation()==160);
			maFormation.setNiveau(5);
			assertTrue(maFormation.coutFormation()==160);
			maFormation.setNiveau(1);
			maFormation.setDuree(10);
			assertTrue(maFormation.coutFormation()==400);
			maFormation.setDuree(-5);
			assertTrue(maFormation.coutFormation()==200);
			
		}
		
		
		
		
		
}
